package com.example.springpoc.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class TestController {
    @GetMapping("/fastjson")
    public void test(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String json = request.getParameter("JSON");
        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
        Object stu2 = JSON.parseObject(json,Object.class);
        System.out.println(stu2);

        ActionMessages messages = new ActionMessages();
        messages.add("msg",new ActionMessage(request.getParameter("json")) );
    }
}